﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Entity;
using Utils.DC.Web.UI;

public partial class Admin_ChangePass : System.Web.UI.UserControl
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login"] != null)
        {

        }
       
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        try
        {
            Admin adminInfo = (Admin)Session["login"];
            Admin admin = new AdminUI().Login(adminInfo.Username, Security.Encrypt(txtOldPass.Text.Trim()));
            if (admin != null)
            {
                lblError.Visible = false;
                AdminUI adminUI = new AdminUI();
                int result = adminUI.ChangePass(adminInfo.Username, Security.Encrypt(txtOldPass.Text.Trim()), Security.Encrypt(txtRepass.Text.Trim()));
                if (result > 0)
                {
                    Response.Write("<script>alert('change password successful');</script>");
                }
                else
                {
                    Response.Write("<script>alert('change password fail');</script>");
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }
        catch (Exception ex)
        {

        }
    }
}
